<?php


namespace app\index\controller;

use think\Db;
use think\exception\DbException;

/**
 * 数据库操作order
 * Class DbOrderTest
 * @package app\index\controller
 */
class DbOrderTest
{
    public function order_test()
    {
        try {
            $res = Db::table('t_user')
                ->field(['id,name,age'])
                ->order('age', 'desc')
                ->select();
            return json(['msg' => '查询成功!', 'data' => $res]);
        } catch (DbException $e) {
            return json(['msg' => '查询失败!', 'data' => $e]);
        }
    }
}